/* ServerInfoProvider.java
 * 
 * Alfred Olschnoegger
 * 24.05.2008
 */

package application;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import application.parser.Parser;
import application.valueObjects.GameValue;
import application.valueObjects.HunterValue;

import domain.Hunter;
import domain.game.Game;
import domain.game.GameManager;

/**
 * Provides informations about the server
 * 
 * @date 24.05.2008
 * @author Alfred Olschnoegger
 */

public class ServerInfoProvider {
	private final Collection<Game> m_Games;
	// private final Collection<Hunter> m_Hunters;
	private static final String s_Version = "0.5.1";

	/**
	 * Default constructor, requests a GameManager
	 */
	public ServerInfoProvider() {
		m_Games = GameManager.getInstance().getGameList();
		// m_Hunters = null;
	}

	/**
	 * reads a list of all games
	 * 
	 * @param i
	 * 
	 * @return list of all games
	 */
	public List<GameValue> getGameValues() {
		List<GameValue> list = new LinkedList<GameValue>();
		for (Game g : m_Games)
			list.add(new GameValue(g.getGameID(), g.getGameName(), g.getHunterCount(), g.getRemainingTimeslice(), g.getArea().getXMax(), g.getArea().getYMax()));

		return list;
	}

	public String getVersion() {
		return s_Version;
	}

	public void getInfo(Parser parse) {
		parse.add(this);
	}

	public void getGames(Parser parse) {
		for (Game g : m_Games) {
			if (g.isRunning()) {
				parse.add(g);
			}
		}
	}


}

// end of ServerInfoProvider.java
